package org.siam.impl.schemas {
	
	import flash.utils.Dictionary;
	
	import org.siam.core.schemas.ISchema;
	import org.siam.core.schemas.ISchemaRegistry;
	
	public class SchemaRegistry implements ISchemaRegistry {
		
		private var _registry:Dictionary;
		
		public function SchemaRegistry() {
			_registry = new Dictionary();
		}
		
		public function register(id:String, schema:ISchema):void {
			_registry[id] = schema;			
		}

		public function has(id:String):Boolean {		
			return _registry.hasOwnProperty(id);
		}

		public function find(id:String):ISchema {
			return has(id) ? _registry[id] : Schema.NULL;
		}
		
		public function get ids():Array {
			var ids:Array = new Array();
			for (var id:String in _registry) {
				ids.push(id);
			}
			return ids;
		}
	}
}